<?php
	$tp = new template('views/shopping/view.html');
	$key		= 'v6hp547'.date('Y-m-d');

	$url = $params[1];
	$cnt_order = (int)count($_SESSION['p_order']);
	extract(select('v_product','url',$url,"$type AND `status` = '1' ORDER BY `date` DESC"), EXTR_PREFIX_ALL , "c");
	
	$tid = $c_category_id;
	$type = $tid ? "AND `category_id` = ".$tid:'';
	
	$pcode		= md5($c_product_id.$key);
	$c_title	= ucfirst($c_title);
	$facebook_description = strip_tags($c_description) ? strip_tags($c_description) : $c_title;

	$colorOptions	= _u(sqlOptions("SELECT `i`.`color_id` AS `value` , `c`.`title` AS `label` FROM `tbl_product_item` AS `i`  LEFT JOIN `tbl_color` AS `c` ON `i`.`color_id` = `c`.`color_id`  WHERE  `i`.`product_id` = '$c_product_id' GROUP BY `i`.`color_id` ORDER BY `i`.`color_id` ASC"),'color');
	/*$sizeOptions	= _u(sqlOptions("SELECT `i`.`size_id` AS `value` , `s`.`title` AS `label` FROM `tbl_product_item` AS `i` LEFT JOIN `tbl_size` AS `s` ON `i`.`size_id` = `s`.`size_id` WHERE `i`.`product_id` = '$c_product_id' ORDER BY `i`.`size_id` ASC"),'size');*/
	
	//gallery
	$sql = "SELECT `gallery_id`,`image` FROM `tbl_product_gallery` WHERE `product_id` = '$c_product_id' ORDER BY `gallery_id` ASC";
	$query = mysql_query($sql);
	$tp->Block('gallery');
	while($result = mysql_fetch_assoc($query)) { 
		$g_image	= $result['image'] ?  $result['image']: "";
		$tp->Apply();
	}
	mysql_free_result($query);

	//brand
	$sql = "SELECT `url`,`thumb` FROM `tbl_brand` ORDER BY `brand_id` ASC LIMIT 13";
	$query = mysql_query($sql);
	$tp->Block('brand');
	while($result = mysql_fetch_assoc($query)) { 
		$brand_url		= $result['url'];
		$brand_thumb	= $result['thumb'] ?  $result['thumb']: "";
		$tp->Apply();
	}
	mysql_free_result($query);

	//products
	$sql = "SELECT `title`,`url`,`thumb`,`brand_url` FROM `v_product` WHERE `brand_id` = '$c_brand_id' $type AND `status` = '1' ORDER BY `date` DESC";
	$query = mysql_query($sql);
	$tp->Block('product');
	while($result = mysql_fetch_assoc($query)) { 
		$p_title	= ucfirst($result['title']);
		$p_url		= $result['url'];
		$p_brand_url= $result['brand_url'];
		$p_thumb	= $result['thumb'] ?  $result['thumb']: "";
		$tp->Apply();
	}
	mysql_free_result($query);
?>